<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" media="screen" href="../../css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="../../css/dataTables.bootstrap.min.css">
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all"/>
</head>
<body>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
    <form class="form-horizontal layui-form" onsubmit="return false" id="form">
        <fieldset>
            <div class='form-group'>
                <label class='col-md-2 control-label'>用户名</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='username' type='text' name='username' id='username'
                           data-bv-notempty='true' data-bv-notempty-message='username 不能为空'>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>用户昵称</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='nickname' type='text' name='nickname' id='nickname'
                           data-bv-notempty='true' data-bv-notempty-message='nickname 不能为空'>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>手机号</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='phone' type='text' name='phone' id='phone'
                           data-bv-notempty='true' data-bv-notempty-message='phone 不能为空'>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>用户状态</label>
                <div class='col-md-10'>

                    <select name="status" class="form-control input-sm" id="status">
                        <option value="1" selected>正常</option>
                        <option value="2">锁定</option>
                    </select>
                </div>
            </div>

            <div class='form-group'>
                <label class='col-md-2 control-label'>真实姓名</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='realname' type='text' name='realname' id='realname'
                           data-bv-notempty='false' data-bv-notempty-message='realname 不能为空'>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>律师执业证号</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='workCode' type='text' name='workCode' id='workCode'
                           data-bv-notempty='false' data-bv-notempty-message='workCode 不能为空'>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>地区名字</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='areaName' type='text' name='areaName' id='areaName'
                           data-bv-notempty='false' data-bv-notempty-message='areaName 不能为空'>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>地区id</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='comid' type='text' name='comid' id='comid'
                           data-bv-notempty='false' data-bv-notempty-message='comid 不能为空'>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>律师所在律所</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='lawfirm' type='text' name='lawfirm' id='lawfirm'
                           data-bv-notempty='false' data-bv-notempty-message='lawfirm 不能为空'>
                </div>
            </div>

            <div class='form-group'>
                <label class='col-md-2 control-label'>身份证号</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='idnumber' type='text' name='idnumber' id='idnumber'
                           data-bv-notempty='false' data-bv-notempty-message='idnumber 不能为空'>
                </div>
            </div>

            <input class='form-control' placeholder='field' type='hidden' name='field' id='field'>

            <div class="form-group">
                <label class="col-md-2 control-label">律师领域</label>
                <div class=" col-md-10">
                    <div id="fuxuankuang">

                    </div>
                </div>
            </div>

            <div class='form-group'>
                <label class='col-md-2 control-label'>律师寄语</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='content' type='text' name='content' id='content'
                           data-bv-notempty='false' data-bv-notempty-message='content 不能为空'>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>教育背景</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='education' type='text' name='education' id='education'
                           data-bv-notempty='false' data-bv-notempty-message='education 不能为空'>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>认证资质</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='thirdlevel' type='text' name='thirdlevel' id='thirdlevel'
                           data-bv-notempty='false' data-bv-notempty-message='thirdlevel 不能为空'>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>律师服务人数</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='serverNumber' type='text' name='serverNumber'
                           id='serverNumber' data-bv-notempty='false' data-bv-notempty-message='serverNumber 不能为空'>
                </div>
            </div>

            <div class='form-group'>
                <label class='col-md-2 control-label'>律师好评率</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='rating' type='text' name='rating' id='rating'
                           data-bv-notempty='false' data-bv-notempty-message='rating 不能为空'>
                </div>
            </div>

            <div class='form-group'>
                <label class='col-md-2 control-label'>律师状态</label>
                <div class='col-md-10'>
                    <select name="lawyerInspect" class="form-control input-sm" id="lawyerInspect">
                        <option value="0">未审核</option>
                        <option value="1" selected>审核通过</option>
                        <option value="2">待审核</option>
                        <option value="3">拒绝</option>
                    </select>
                </div>
            </div>


            <div class="form-actions">
                <div class="row" align="center">
                    <div class="col-md-12">
                        <button class="btn btn-primary" onclick="location.href='mfflLawyerList.html'">返回</button>
                        <button class="btn btn-primary" id="save" type="submit" onclick="add()">
                            <i class="fa fa-save"></i> 保存
                        </button>
                    </div>
                </div>
            </div>

        </fieldset>
    </form>
</div>
<script type="text/javascript" src="../../js/libs/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../js/jq.js"></script>
<script type="text/javascript" src="../../js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
<script type="text/javascript" src="../../js/common.js"></script>
<!--<script type="text/javascript" src="../../layui/layui.js"></script>-->
<script type="text/javascript" src="../../layui/layui.all.js"></script>
<script type="text/javascript">
    layui.use(['form', 'layer', 'laydate'], function () {
        var form = layui.form;
        var layer = layui.layer;
    });

    initData();

    function initData() {
        $.ajax({
            type: 'get',
            url: '/client/mfflTypes/getLawyerType',
            async: false,
            success: function (data) {
                console.log(data);
                var lawyerType = data.datas;
                for (var i = 0; i < lawyerType.length; i++) {
                    $('#fuxuankuang').append('<input type="checkbox"  name="fxk" value="' + lawyerType[i].id + '" title="' + lawyerType[i].name + '" >')
                }
                var form = layui.form
                form.render();
            }
        });
    }


    function add() {
        $('#form').bootstrapValidator();
        var bootstrapValidator = $("#form").data('bootstrapValidator');
        bootstrapValidator.validate();
        if (!bootstrapValidator.isValid()) {
            return;
        }
        var arr = new Array();
        $("input:checkbox[name='fxk']:checked").each(function (i) {
            arr[i] = $(this).val();
        })
        var formdata = $("#form").serializeObject();
        formdata.field = arr.join(",");

        $.ajax({
            type: 'post',
            url: '/mfflLawyer',
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(formdata),
            success: function (data) {
                if (data.errCode == '200') {
                    layer.msg("添加成功", {shift: -1, time: 1000}, function () {
                        location.href = "mfflLawyerList.html";
                    });
                } else {
                    layer.msg(data.message);
                    document.getElementById("save").removeAttribute("disabled");
                }


            }
        });
    }

</script>
</body>
</html>
